package com.example.swordkotlin

object Test15 {

    @JvmStatic
    fun main(args: Array<String>) {
        val pre = intArrayOf(1, 2, 4, 7, 3, 5, 6, 8)
        val vin = intArrayOf(4, 7, 2, 1, 5, 3, 8, 6)
    }

    class TreeNode(var `val`: Int, var left: TreeNode? = null, var right: TreeNode? = null)


    /**
     * 二进制中1的个数
     */

    fun NumberOf1(n: Int): Int {
        // write code here
        var count = 0
        var num = n
        while (num != 0) {
            count++
            num = num and num - 1
        }
        return count
    }
}